﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TraceabilityApp_Api.Application.Command.Slaughter_屠宰_;
using TraceabilityApp_Api.DTO;
using TraceabilityApp_ErrorCode;

namespace TraceabilityApp_Api.Controllers
{
    /// <summary>
    /// 屠宰控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SlaughterController : ControllerBase
    {
        private readonly IMediator mediator;

        public SlaughterController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        ///屠宰信息添加
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddSlaughter(AddSlaughterCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        ///屠宰信息修改
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> UpdateSlaughter(UpdateSlaughterCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 屠宰信息列表
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<SlaughterDTO>> GetSlaughter([FromQuery]GetSlaughterCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 屠宰企业信息添加
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddCompany(AddCompanyCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 屠宰企业信息修改
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> UpdateCompany(UpdateCompanyCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 屠宰企业信息显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<CompanyDTO>> GetCompany([FromQuery]GetCompanyCommand request)
        {
            return mediator.Send(request);
        }
    }
}
